package com.mall.common.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONArray;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.WebUtils;

import com.mall.common.service.AreaService;
import com.mall.untils.Page;

/**
 * 地区接口
 * 
 * @ClassName: areaController
 * @Description:
 * @author:wangwenyue wangwenyue@ide365.com
 * @date 2016年7月8日 上午11:10:21
 */
@RequestMapping("/manager")
@Controller
public class AreaController {

	Logger logger = LoggerFactory.getLogger(AreaController.class);

	@Resource
	AreaService areaService;

	/**
	 * 分页
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/area_list")
	@ResponseBody
	public String area_list(HttpServletRequest request) {
		Page area_list = areaService.area_list(WebUtils.getParametersStartingWith(request, ""));
		JSONArray jsonArray = JSONArray.fromObject(area_list);
		return String.valueOf(jsonArray);
	}

	/**
	 * 增加地区
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/area_add")
	@ResponseBody
	public String area_add(HttpServletRequest request) {
		int area_add = areaService.area_add(WebUtils.getParametersStartingWith(request, ""));
		return String.valueOf(area_add);
	}

	/**
	 * 删除地区
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/area_rem")
	@ResponseBody
	public String area_rem(HttpServletRequest request) {
		int area_rem = areaService.area_rem(WebUtils.getParametersStartingWith(request, ""));
		return String.valueOf(area_rem);
	}

	/**
	 * 修改地区
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/area_update")
	@ResponseBody
	public String area_update(HttpServletRequest request) {
		int area_update = areaService.area_update(WebUtils.getParametersStartingWith(request, ""));
		return String.valueOf(area_update);
	}

}
